package model;

import java.util.LinkedList;
import java.util.List;

import model.semantics.ConstNode;
import model.semantics.Node;
import model.turtle.Turtle;
import model.turtle.Position;

public class TurtleState extends State<Integer> {

	private List<Turtle> myTurtles;
	private int turtleIndex;
	private Position initialPos;
	
	public TurtleState() {
		initialPos = new Position(0,0,90);
		myTurtles = new LinkedList<Turtle>();
		myTurtles.add(new Turtle(initialPos));
		turtleIndex = 0;
	}
	
	public Turtle getTurtle() {
		return myTurtles.get(turtleIndex);
	}
	
	public void setTurtle(int index){
		if(myTurtles.size()>=(index+1))
			turtleIndex = index;
		else{
			int tmp = myTurtles.size();
			for(int i=0; i<(index+1-tmp); i++){
				myTurtles.add(new Turtle(initialPos));
			}
			turtleIndex = index;
		}
	}
	
	@Override
	protected Node<Integer> getDefaultValue() {
		return new ConstNode(0);
	}
	
	public List<Turtle> getTurtleList(){
		return myTurtles;
	}

}
